package org.xiaojinlong.simulation;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jin Long
 * 2015/9/23
 */
public class Type {
    interface A {
        void a();
    }

    interface B {
        void b();
    }

    static class AA implements A {
        @Override
        public void a() {
            System.out.println("a");
        }
    }

    static class AB implements A, B {
        @Override
        public void a() {
            System.out.println("aa");
        }

        @Override
        public void b() {
            System.out.println("ab");
        }
    }

    public static void main(String[] args) {
        List<A> aList = new ArrayList<>();
        aList.add(new AA());
        aList.add(new AB());
        for (A a : aList)
            if (a instanceof B)
                ((B) a).b();
    }
}
